{
	template:`
    <m-page @back="back" :title="title">
        <m-top></m-top>
        <m-title>{{title}}
			<template #action>
				<m-button @click="openDetail({status:'Y',user:{},storeCheck:'Y',accountDay:'15'})">新增</m-button>
			</template>
        </m-title>
		<m-top></m-top>
		<m-list ref="list" :url="url" :params="params" :bottom="0" :search="search">
			<template #item="{item}">
				<m-card join @click="openDetail(item)">
					<div class="flex padding-sm align-center">
                        <div class="cu-tag radius" :class="'bg-'+item.color">{{item.name}}</div>
						<div class="flex-sub padding-lr-sm">
						    <div>{{item.tel}}</div>
						    <div class="text-sm">{{item.address}}</div>
						    <div class="padding-top-xs text-sm text-blue">账期止{{dict('member.base.model.StoreInfo!accountDay',item.accountDay)}}{{item.storeCheck=='Y'?'，店长审核已开启':''}}</div>
						</div>
						<div class="text-right text-sm">
						    <div class="padding-bottom-xs">{{item.user.realName}}</div>
						    <div>{{item.user.phoneNum}}</div>
						</div>
					</div>
				</m-card>
			</template>
		</m-list>
		<m-modal ref="detail" title="店铺信息" @close="$refs.list.refresh()">
			<div v-if="showDetail">
				<m-card>
                    <div class="cu-form-group">
                        <div class="title text-red">颜色</div>
                        <m-select-color v-model="showDetail.color"></m-select-color>
                    </div>
                    <div class="cu-form-group">
                        <div class="title text-red">店铺名称</div>
                        <m-input v-model="showDetail.name" placeholder="请输入店铺名称"></m-input>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">电话</div>
                        <m-input v-model="showDetail.tel" placeholder="请输入电话"></m-input>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">地址</div>
                        <m-input v-model="showDetail.address" placeholder="请输入地址"></m-input>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">店长</div>
                        <m-form-item>
                            <div v-if="showDetail.user.oid">{{showDetail.user.realName}} <span class="text-sm">{{showDetail.user.phoneNum}}</span></div>
                            <div v-else class="text-placeholder">请选择店长</div>
                            <template #action>
                                <m-button @click="selectUser(showDetail)" size="sm">选择</m-button>
                            </template>
                        </m-form-item>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">店长审核</div>
                        <m-dict-option class="flex-sub" v-model="showDetail.storeCheck" type="member.base.model.StoreInfo!storeCheck"></m-dict-option>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">账期止</div>
                        <m-dict-option class="flex-sub" v-model="showDetail.accountDay" type="member.base.model.StoreInfo!accountDay"></m-dict-option>
                    </div>
				</m-card>
                <div class="flex padding-lr-sm padding-bottom">
                    <div class="flex-sub flex flex-direction padding-lr-xs">
                        <m-button @click="closeDetail()" line>关闭</m-button>
                    </div>
                    <div class="flex-sub flex flex-direction padding-lr-xs">
                        <m-button @click="save">保存</m-button>
                    </div>
                </div>
			</div>
		</m-modal>
    </m-page>
	`,
	props: ['param','parentVue'],
	data:function(){
		return {
            title:'店铺管理',
            url:'action/base/storeInfo/getList',
            params:{},
            search:[
                {title:'名称',name:'name@like',input:'text'}
            ],
            showDetail:null
		};
	},
	mounted(){
	},
	methods:{
        openDetail:function(item){
            this.showDetail=Object.assign({},item);
            this.$refs.detail.open();
        },
        closeDetail:function(){
            this.$refs.detail.close();
        },
        selectUser:function(model){
            let selectOid=model.user?model.user.oid:'';
	        this.openPage('common/selectUser.js',{title:'选择店长',selectOid:selectOid},(flag,obj)=>{
	            if(flag){
	                model.user=obj;
                }
	        });
        },
        save:function(){
            this.requestData('action/base/storeInfo/save',
                {model:this.showDetail},
                (data)=>{
                    if(data.code==0){
                        this.remind().success(data.msg);
                        this.closeDetail();
                    }else{
                        this.remind().error(data.msg);
                    }
                }
            );
        }
	}
}